<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/common/header::common-head">
    <!--<#include "../common/header.html">-->
</head>
<body>
    <!--边栏-->
    <!--<#include "../common/nav.html">-->
    <div th:replace="admin/common/nav::common-nav" ></div>
    <!--<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.css" rel="stylesheet">-->
    <script src="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/js/bootstrap.min.js"></script>

    <div class="content-wrapper" style="width: auto">
        <div class="container">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <div name="search" class="col-md-6 row-md-6">
                            <div class="input-group">
                                <select id="searchType" class="btn btn-primary" style="width: 100px;text-align: center;">
                                    <option class="btn btn-primary" value="名称">名称</option>
                                    <option class="btn btn-primary" value="编号">编号</option>
                                </select>
                                <input class="form-control" type="text" placeholder="Search for..." id="search">
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="button" id="enterSearch" onclick="searchCategory()">
                                        <i class="fa fa-search"></i>
                                    </button>
                                 </span>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button" class="btn btn-lg active"><a href="addpage"> 添加商品分类</a></button>

                            </div>
                    </div>
                    <table class="table">
                        <thead>
                            <tr>
                                <th>
                                    商品类别编号
                                </th>
                                <th>
                                    商品类别名称
                                </th>
                                <th>
                                    商品类别描述
                                </th>
                                <th>
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>

                            <tr class="success" th:each="category :${categoryList}" >
                                <td th:text="${category.categoryId}">

                                </td>
                                <td th:text="${category.categoryName}">

                                </td>
                                <td th:text="${category.categoryDescribe}">

                                <td>
                                    <a th:href="@{/category/update(id=${category.categoryId})}">修改</a>
                                    &nbsp;&nbsp;
                                    <a th:href="@{/category/delete(id=${category.categoryId})}" id="deleteCategory" class="deleteCategory" >删除</a>
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>



        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".deleteCategory").click(function () {
                    var message = "您确定要删除吗？";
                    if (confirm(message)==true){
                        return true;
                    }
                    return false;

                });
                // $("#enterSearch").click(function () {
                //    if($("#serchType").val()=="名称"){
                //        var url = "/category/selectByName?"+$("#search").val();
                //        window.open(url);
                //    }
                //     if($("#serchType").val()=="编号"){
                //         var url = "/category/selectById?"+$("#search").val();
                //         window.open(url);
                //     }
                // });
                
            });

        </script>
        <script>
            function searchCategory() {
                var serch = document.getElementById("search");
                if (document.getElementById("searchType").value=="名称"){
                    var url = "/fashionpress/category/selectByName/"+serch.value;
                    window.location.href=url;
                }
                if (document.getElementById("searchType").value=="编号"){
                    var url = "/fashionpress/category/selectById/"+serch.value;
                    window.location.href=url;
                }

            }
        </script>

    </div>
    <div th:replace="admin/common/footer::common-footer"/>
</body>
</html>